package com.mtsmda.designPattern.singleton;

import java.lang.reflect.Constructor;

public class ReflectionDestroySingletonRun {
	
	public static void main(String[] args) {
		EagerInitializedSingleton eagerInitializedSingleton = EagerInitializedSingleton.getInstance();
		EagerInitializedSingleton eagerInitializedSingleton2 = null;
		System.out.println(eagerInitializedSingleton != null);
		System.out.println(eagerInitializedSingleton2 != null);
		
		try {
			Constructor<?> [] constructors = EagerInitializedSingleton.class.getDeclaredConstructors();
			for(Constructor<?> constructor : constructors){
				constructor.setAccessible(true);
				eagerInitializedSingleton2 = (EagerInitializedSingleton) constructor.newInstance();
				break;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println(eagerInitializedSingleton != null);
		System.out.println(eagerInitializedSingleton2 != null);
		System.out.println(eagerInitializedSingleton.hashCode());
		System.out.println(eagerInitializedSingleton2.hashCode());
		
	}
	
}